package com.czy.owner.adapter;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.czy.owner.ui.BaseFragment;

import java.util.List;

public class CommonTabLayoutAdapter extends FragmentStatePagerAdapter {
    private List<String> mTitles;
    private  List<BaseFragment>mFragments;
    public CommonTabLayoutAdapter(FragmentManager fm, List<BaseFragment>mFragments, List<String> titles) {
        super(fm);
        this.mTitles = titles;
        this.mFragments = mFragments;
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Override
    public BaseFragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position);
    }

    public void reloadFragment(int position){
        mFragments.get(position).reloadData();
    }
}
